from openpyxl import Workbook

# 创建一个Workbook对象，这就相当于创建了一个Excel文件
wb = Workbook()

# 激活worksheet
ws = wb.active

# 给单元格赋值
ws['A1'] = 42
ws['B1'] = 'Hello, world!'
ws['A2'] = 'Python'
ws['B2'] = 'Excel'
ws['C1'] = '谢卓宇'

# 保存Workbook对象，这相当于保存了Excel文件
#wb.save("D:/Program Files/python/file/sample.xlsx")
wb.save("sample.xlsx")